﻿<%@ Page Language="C#" MasterPageFile="~/ClientsMaster.master" AutoEventWireup="true" CodeFile="SpravaUctu.aspx.cs" Inherits="Clients_SpravaUctu" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cph_content" Runat="Server">

<h1>Správa uživatelského učtu</h1>

<h2>Informace o učtu</h2>
<asp:DetailsView ID="viewAccount" runat="server" Height="50px" Width="597px"
        DataSourceID="sourceAccount" 
        BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" 
        CellPadding="2" ForeColor="Black" GridLines="None" AutoGenerateRows="False">
        <FooterStyle BackColor="Tan" />
        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" 
            HorizontalAlign="Center" />
        <HeaderStyle BackColor="Tan" Font-Bold="True" />
        <EditRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
        <AlternatingRowStyle BackColor="PaleGoldenrod" />
        <Fields>
            <asp:BoundField DataField="Balance" HeaderText="Zůstatek na ůčtu" ReadOnly="true" />
            <asp:TemplateField HeaderText="Datum vytvoření účtu">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Membership.GetUser(DatabaseManager.getPersonByAccont(Eval("Id").ToString()).Email).CreationDate  %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="IncomesCount" HeaderText="Příchozích položek" />
            <asp:BoundField DataField="OutcomesCount" HeaderText="Odchozich plateb" />  
            <asp:TemplateField HeaderText="Poslední přihlášení">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Membership.GetUser(DatabaseManager.getPersonByAccont(Eval("Id").ToString()).Email).LastLoginDate  %>' />
                </ItemTemplate>
            </asp:TemplateField>
        </Fields>
    </asp:DetailsView>

<h2>Editace osobních údajů</h2>
    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="597px" 
        DataSourceID="sourcePerson" 
        BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" 
        CellPadding="2" ForeColor="Black" GridLines="None" AutoGenerateEditButton="True" AutoGenerateRows="False">
        <FooterStyle BackColor="Tan" />
        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" 
            HorizontalAlign="Center" />
        <HeaderStyle BackColor="Tan" Font-Bold="True" />
        <EditRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
        <AlternatingRowStyle BackColor="PaleGoldenrod" />
        <Fields>
            <asp:BoundField DataField="email" HeaderText="Email" ReadOnly="true" />
            <asp:BoundField DataField="FirstName" HeaderText="Jméno" />
            <asp:BoundField DataField="LastName" HeaderText="Příjmení" />
            <asp:BoundField DataField="AcademicalDegree" HeaderText="Titul" />
            <asp:BoundField DataField="Phone" HeaderText="Phone" />
            <asp:BoundField DataField="Street" HeaderText="Ulice" />
            <asp:BoundField DataField="City" HeaderText="Mesto" />
            <asp:BoundField DataField="PostalCode" HeaderText="PSČ" />  
        </Fields>
    </asp:DetailsView>


    <asp:ObjectDataSource ID="sourcePerson" runat="server" 
        SelectMethod="getPerson" UpdateMethod="editPerson" TypeName="DatabaseManager" DataObjectTypeName="Person">
        <SelectParameters>
            <asp:Parameter Name="email" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="editedPerson"  />
        </UpdateParameters>
    </asp:ObjectDataSource>

    <asp:ObjectDataSource ID="sourceAccount" runat="server" 
        SelectMethod="getAccount" UpdateMethod="editAccount" TypeName="DatabaseManager" DataObjectTypeName="Account">
        <SelectParameters>
            <asp:Parameter Name="id" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="editedAccount"  />
        </UpdateParameters>
    </asp:ObjectDataSource>

    <asp:Button ID="cmd_DeleteAccount" runat="server" Text="Zrušit učet" 
        onclick="cmd_DeleteAccount_Click" OnClientClick="javascript: return confirm('Opravdu chcete smazat svuj učet?')"/>
  
</asp:Content>

